package com.health.tablebean.webservice;

import android.content.Context;
import android.text.TextUtils;


import com.health.db.FDbManager;
import com.health.tablebean.GRAVIDA_BASEINFO;
import com.health.tablebean.GRAVIDA_POSTPARTUM;
import com.health.tablebean.GRAVIDA_POSTPARTUM_42DAY;
import com.health.viewscontrols.NovaApplication;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

/**
 * 孕产妇产后42天健康检查上传接口
 *
 * @author wangxiangyi
 * @date 2018/04/21
 */
public class MaternalFortyTwoDaysVisits {
    /**
     * 身份证（现做证件号码）
     */
    private String cardid;
    /**
     * 乳房红肿检查结果标志：
     * DM01-40_1 未见异常，
     * DM01-40_2 异常
     */
    private String breast;
    /**
     * 乳房异常描述
     */
    private String breastDesc;
    /**
     * 检查结果分类：
     * DM06-5_1 已恢复,
     * DM06-5_1 未恢复
     */
    private String checkResultClassification;
    /**
     * 创建机构
     */
    private String createorg;
    /**
     * 创建人
     */
    private String creater;
    /**
     * 创建时间
     */
    private String createtime;
    /**
     * 伤口愈合状况代码：
     * DM01-40_1 未见异常，
     * DM01-40_2 异常
     */
    private String cut;
    /**
     * 伤口异常描述
     */
    private String cutDesc;
    /**
     * 舒张压(mmHg)'
     */
    private String dbp;
    /**
     * 处理代码组合：
     * DM06-3_1 结案，
     * DM06-3_2 转诊
     */
    private String dispose;
    /**
     * 检查日期
     */
    private String examDate;
    /**
     * 随访医生签名
     */
    private String examDoctor;
    /**
     * 胎次
     */
    private String fetusTimes;
    /**
     * 健康指导代码组合：
     * DM06-03_12 心理保健，
     * DM06-03_13 性保健及避孕，
     * DM06-03_11 婴儿喂养，
     * DM06-03_16 产妇营养，
     * DM06-03_99 其他
     */
    private String healthInstruction;
    /**
     * 健康指导其他描述
     */
    private String healthOther;
    /**
     * 一般健康状况
     */
    private String healthState;
    /**
     * 恶露异常情况描述
     */
    private String lymaDesc;
    /**
     * 其他异常情况
     */
    private String otherState;
    /**
     * 一般心里状况
     */
    private String psychologyState;
    /**
     * 未恢复情况描述
     */
    private String recoveryDesc;
    /**
     * 分娩时间
     */
    private String res5;
    /**
     * 出院时间
     */
    private String res6;
    /**
     * 收缩压( mHg)
     */
    private String sbp;
    /**
     * 恶露状况代码：
     * DM01-40_1 未见异常，
     * DM01-40_2 异常
     */
    private String smellMark;
    /**
     * 子宫检查结果：
     * DM01-40_1 未见异常，
     * DM01-40_2 异常
     */
    private String uterine;
    /**
     * 子宫异常描述
     */
    private String uterineDesc;
    /**
     * 转诊原因、转诊机构及科室
     */
    private Rollout rollOut;

    public String getCardid() {
        return cardid;
    }

    public void setCardid(String cardid) {
        this.cardid = cardid;
    }

    public String getBreast() {
        return breast;
    }

    public void setBreast(String breast) {
        this.breast = breast;
    }

    public String getBreastDesc() {
        return breastDesc;
    }

    public void setBreastDesc(String breastDesc) {
        this.breastDesc = breastDesc;
    }

    public String getCheckResultClassification() {
        return checkResultClassification;
    }

    public void setCheckResultClassification(String checkResultClassification) {
        this.checkResultClassification = checkResultClassification;
    }

    public String getCreateorg() {
        return createorg;
    }

    public void setCreateorg(String createorg) {
        this.createorg = createorg;
    }

    public String getCreater() {
        return creater;
    }

    public void setCreater(String creater) {
        this.creater = creater;
    }

    public String getCreatetime() {
        return createtime;
    }

    public void setCreatetime(String createtime) {
        this.createtime = createtime;
    }

    public String getCut() {
        return cut;
    }

    public void setCut(String cut) {
        this.cut = cut;
    }

    public String getCutDesc() {
        return cutDesc;
    }

    public void setCutDesc(String cutDesc) {
        this.cutDesc = cutDesc;
    }

    public String getDbp() {
        return dbp;
    }

    public void setDbp(String dbp) {
        this.dbp = dbp;
    }

    public String getDispose() {
        return dispose;
    }

    public void setDispose(String dispose) {
        this.dispose = dispose;
    }

    public String getExamDate() {
        return examDate;
    }

    public void setExamDate(String examDate) {
        this.examDate = examDate;
    }

    public String getExamDoctor() {
        return examDoctor;
    }

    public void setExamDoctor(String examDoctor) {
        this.examDoctor = examDoctor;
    }

    public String getFetusTimes() {
        return fetusTimes;
    }

    public void setFetusTimes(String fetusTimes) {
        this.fetusTimes = fetusTimes;
    }

    public String getHealthInstruction() {
        return healthInstruction;
    }

    public void setHealthInstruction(String healthInstruction) {
        this.healthInstruction = healthInstruction;
    }

    public String getHealthOther() {
        return healthOther;
    }

    public void setHealthOther(String healthOther) {
        this.healthOther = healthOther;
    }

    public String getHealthState() {
        return healthState;
    }

    public void setHealthState(String healthState) {
        this.healthState = healthState;
    }

    public String getLymaDesc() {
        return lymaDesc;
    }

    public void setLymaDesc(String lymaDesc) {
        this.lymaDesc = lymaDesc;
    }

    public String getOtherState() {
        return otherState;
    }

    public void setOtherState(String otherState) {
        this.otherState = otherState;
    }

    public String getPsychologyState() {
        return psychologyState;
    }

    public void setPsychologyState(String psychologyState) {
        this.psychologyState = psychologyState;
    }

    public String getRecoveryDesc() {
        return recoveryDesc;
    }

    public void setRecoveryDesc(String recoveryDesc) {
        this.recoveryDesc = recoveryDesc;
    }

    public String getRes5() {
        return res5;
    }

    public void setRes5(String res5) {
        this.res5 = res5;
    }

    public String getRes6() {
        return res6;
    }

    public void setRes6(String res6) {
        this.res6 = res6;
    }

    public String getSbp() {
        return sbp;
    }

    public void setSbp(String sbp) {
        this.sbp = sbp;
    }

    public String getSmellMark() {
        return smellMark;
    }

    public void setSmellMark(String smellMark) {
        this.smellMark = smellMark;
    }

    public String getUterine() {
        return uterine;
    }

    public void setUterine(String uterine) {
        this.uterine = uterine;
    }

    public String getUterineDesc() {
        return uterineDesc;
    }

    public void setUterineDesc(String uterineDesc) {
        this.uterineDesc = uterineDesc;
    }

    public Rollout getRollOut() {
        return rollOut;
    }

    public void setRollOut(Rollout rollOut) {
        this.rollOut = rollOut;
    }

    /**
     * 第一次产前访视接口参数
     *
     * @param context 上下文
     * @return
     */
    public static List<MaternalFortyTwoDaysVisits> convertData(Context context) {
        List<MaternalFortyTwoDaysVisits> datas = new ArrayList<>();

        FDbManager fdb = FDbManager.getInstance(context);
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        if (null == NovaApplication.getUserInfo()) {
            return datas;
        }
        List<GRAVIDA_POSTPARTUM_42DAY> infos = fdb.findAllByWhere(GRAVIDA_POSTPARTUM_42DAY.class,
                "IDCARD='" + NovaApplication.getUserInfo().getIDCARD() + "'");

        if (infos != null && !infos.isEmpty()) {
            for (GRAVIDA_POSTPARTUM_42DAY info : infos) {
                MaternalFortyTwoDaysVisits maternalPostnatalVisits = new MaternalFortyTwoDaysVisits();
                /*身份证号*/
                maternalPostnatalVisits.setCardid(TextUtils.isEmpty(info.getIDCARD()) ? "" : info.getIDCARD().toUpperCase());
                /*获取孕妇基本信息*/
                List<GRAVIDA_BASEINFO> gradicas = fdb.findAllByWhere(GRAVIDA_BASEINFO.class,
                        "IDCARD = '" + info.getIDCARD() + "'");
                if (gradicas.size() > 0) {
                    /*产次*/
                    maternalPostnatalVisits.setFetusTimes(TextUtils.isEmpty(gradicas.get(0).getFetusTimes()) ? "" : gradicas.get(0).getFetusTimes());
                }
                /*随访时间*/
                if (info.getFOLLOWUP_DATE() != null) {
                    maternalPostnatalVisits.setExamDate(formatter.format(info.getFOLLOWUP_DATE()));
                }
                /*分娩日期*/
                if (info.getDeliveryTime() != null) {
                    maternalPostnatalVisits.setRes5(formatter.format(info.getDeliveryTime()));
                }
                /*出院日期*/
                if (info.getDischargeTime() != null) {
                    maternalPostnatalVisits.setRes6(formatter.format(info.getDischargeTime()));
                }
                /*一般健康情况*/
                maternalPostnatalVisits.setHealthState(TextUtils.isEmpty(info.getHEALTHCONDITION()) ? "" : info.getHEALTHCONDITION());
                /*一般心里状况*/
                maternalPostnatalVisits.setPsychologyState(TextUtils.isEmpty(info.getMENTALCONDITION()) ? "" : info.getMENTALCONDITION());
                /*收缩血压*/
                maternalPostnatalVisits.setSbp(TextUtils.isEmpty(info.getHBLOODPRESSURE()) ? "" : info.getHBLOODPRESSURE());
                /*舒长血压*/
                maternalPostnatalVisits.setDbp(TextUtils.isEmpty(info.getLBLOODPRESSURE()) ? "" : info.getLBLOODPRESSURE());
                /*乳房*/
                maternalPostnatalVisits.setBreast(TextUtils.isEmpty(info.getBREAST()) ? "" : info.getBREAST());
                /*乳房异常*/
                maternalPostnatalVisits.setBreastDesc(TextUtils.isEmpty(info.getBREAST_EX()) ? "" : info.getBREAST_EX());
                /*恶露*/
                maternalPostnatalVisits.setSmellMark(TextUtils.isEmpty(info.getLOCHIA()) ? "" : info.getLOCHIA());
                /*恶露异常*/
                maternalPostnatalVisits.setLymaDesc(TextUtils.isEmpty(info.getLOCHIA_EX()) ? "" : info.getLOCHIA_EX());
                /*子宫*/
                maternalPostnatalVisits.setUterine(TextUtils.isEmpty(info.getUTERUS()) ? "" : info.getUTERUS());
                /*子宫异常*/
                maternalPostnatalVisits.setUterineDesc(TextUtils.isEmpty(info.getUTERUS_EX()) ? "" : info.getUTERUS_EX());
                /*伤口*/
                maternalPostnatalVisits.setCut(TextUtils.isEmpty(info.getWOUND()) ? "" : info.getWOUND());
                /*伤口异常*/
                maternalPostnatalVisits.setCutDesc(TextUtils.isEmpty(info.getWOUND_EX()) ? "" : info.getWOUND_EX());
                /*其他*/
                maternalPostnatalVisits.setOtherState(TextUtils.isEmpty(info.getOTHER()) ? "" : info.getOTHER());
                /*分类*/
                maternalPostnatalVisits.setCheckResultClassification(TextUtils.isEmpty(info.getCLASSIFICATION()) ? "" : info.getCLASSIFICATION());
                /*分类异常*/
                maternalPostnatalVisits.setRecoveryDesc(TextUtils.isEmpty(info.getCLASSIFICATION_EX()) ? "" : info.getCLASSIFICATION_EX());
                /*指导*/
                maternalPostnatalVisits.setHealthInstruction(TextUtils.isEmpty(info.getADVISING()) ? "" : info.getADVISING());
                /*指导异常*/
                maternalPostnatalVisits.setHealthOther(TextUtils.isEmpty(info.getADVISINGOTHER()) ? "" : info.getADVISINGOTHER());
                /*处理*/
                maternalPostnatalVisits.setDispose(TextUtils.isEmpty(info.getTREAT()) ? "" : info.getTREAT());
                /*处理原因、机构及科室*/
                Rollout rollOut = new Rollout();
                rollOut.setHpc(info.getREFERRALREASON());
                rollOut.setRollInRegion(info.getREFERRALORG());
                maternalPostnatalVisits.setRollOut(rollOut);
                /*随访医生签名*/
                maternalPostnatalVisits.setExamDoctor(TextUtils.isEmpty(info.getFOLLOWUPDOCTOR()) ? "" : info.getFOLLOWUPDOCTOR());
                /*创建人*/
                maternalPostnatalVisits.setCreater(TextUtils.isEmpty(info.getCREATER()) ? "" : info.getCREATER());
                /*创建机构*/
                maternalPostnatalVisits.setCreateorg(TextUtils.isEmpty(info.getCREATEORG()) ? "" : info.getCREATEORG());
                /*添加list里面*/
                datas.add(maternalPostnatalVisits);
            }
        }
        return datas;
    }
}
